import { GetGoodsDetailData } from '@/api';
const actions = {
	async getGoodsDetailData({ commit }, id) {
		const result = await GetGoodsDetailData({ id});
		if (result.errno === 0) {
			// 这里判断他errno==0成功
			commit('SAVE_GOODDETAIL_INFO', result.data);
			console.log(result.data);
		} else {
			alert(result.message);
		}
	},
};
const mutations = {
	SAVE_GOODDETAIL_INFO(state, detailInfo) {
		state.goodDetailInfo = detailInfo;
	},
};
const state = {
	goodDetailInfo: {
		info: {
			name: '',
			retail_price: '',
		},
		gallery: [],
		attribute: [{ name: '', value: '' }],
	},
};
const getters = {};
export default {
	namespaced: true,
	actions,
	mutations,
	state,
	getters,
};
